<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body{
        margin: 0;
        padding: 0;
    }
    span{
        position: absolute;
        cursor: default;
        font-size: 40px;
        left: 0;
        top: 0;
        line-height: 1;
        /* 取消元素点击拖动会选中的效果 */
        /* -webkit-user-select:none; 
       -moz-user-select:none; 
       -ms-user-select:none; 
       user-select:none; */
    }
</style>
<body>
    <span>★</span>
    <script>
        document.addEventListener('mousemove',function(e){
            let x = e.pageX;
            let y = e.pageY;
            let spanDom = document.getElementsByTagName('span')[0];
            //禁止选中文本的效果，和上面css取消用户选中效果一样
            spanDom.onselectstart = function(){
                return false;
            }
            spanDom.style.left = x - spanDom.offsetWidth/2 + 'px';
            spanDom.style.top = y - spanDom.offsetHeight/2 + 'px';
        },false)
    </script>
</body>
</html>